#include <bits/stdc++.h>
using namespace std;
const int N = 1e4 + 10;

int n;
int a[N][2];

int solve(int x)
{
	a[1][0] = x;
	for(int i = 2;i <= n + 1;i ++)
	{
		a[i][0] = a[i - 1][1] - a[i - 2][0] - a[i - 1][0];
		if(a[i][0] > 1 || a[i][0] < 0) return 0;
	}
	if(a[n + 1][0]) return 0;
	return 1;
}

int main()
{
	cin >> n;
	for(int i = 1;i <= n;i ++) cin >> a[i][1];
	cout << solve(1) + solve(0) << endl;
	return 0;
}